import React, { Component } from 'react'

export default class SetState extends Component {
  constructor(){
    super();
    this.state={
      data:1
    }
  }
  componentDidMount(){
    this.setState(prevState => {
      return {
        data : prevState.data + 1
      }
    })
    this.setState(prevState => {
      return {
        data : prevState.data + 1
      }
    })
  }
  render() {
    console.log(this.props.title)
    const title = this.props.title ? <h1>{this.props.title}</h1> : null;
    return (
      <div>
        {title}
        {this.props.title && <h1>{this.props.title}</h1>}
        {this.state.data}
      </div>
    )
  }
}
